package com.itheima.consumer.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created with IntelliJ IDEA 2023.
 * Description:
 * User: homechen
 * Date: 2024-04-20
 * Time: 19:37
 */
@Configuration
public class FanoutQueue {
    @Bean
    public FanoutExchange fanoutExchange() {
        return new FanoutExchange("ttt.fanout2");   // 创建交换机
    }

    @Bean
    public Queue fanoutQueue3() {
        return new Queue("fanout.queue3");  // 创建fanout队列
    }

    @Bean
    public Binding bindingQueue1(FanoutExchange fanoutExchange, Queue fanoutQueue3) {
        return BindingBuilder.bind(fanoutQueue3).to(fanoutExchange);
    }
}
